@model RecurringPaymentModel

<div class="panel-body">
    @if (Model.LastPaymentFailed)
    {
        <div class="form-group">
            <div class="col-md-12">
                @T("Admin.RecurringPayments.History.LastPaymentFailed")
            </div>
        </div>
    }
    @if (!string.IsNullOrEmpty(Model.NextPaymentDate))
    {
        <div class="form-group">
            <div class="col-md-12">
                @T("Admin.RecurringPayments.History.NextPaymentDate")
                <text>:</text>
                @Model.NextPaymentDate
            </div>
        </div>
    }
    @if (!string.IsNullOrEmpty(Model.NextPaymentDate) || Model.CanCancelRecurringPayment)
    {
        <div class="form-group">
            <div class="col-md-12">
                @if (!string.IsNullOrEmpty(Model.NextPaymentDate))
                {
                    <button type="submit" name="processnextpayment" class="btn bg-green">
                        @T("Admin.RecurringPayments.History.ProcessNextPayment")
                    </button>
                }
                @if (Model.CanCancelRecurringPayment)
                {
                    <button type="submit" name="cancelpayment" class="btn bg-navy">
                        @T("Admin.RecurringPayments.History.CancelPayment")
                    </button>
                }
            </div>
        </div>
    }

    @await Html.PartialAsync("Table", new DataTablesModel
    {
        Name = "history-grid",
        UrlRead = new DataUrl("HistoryList", "RecurringPayment", new RouteValueDictionary { [nameof(Model.RecurringPaymentHistorySearchModel.RecurringPaymentId)] = Model.RecurringPaymentHistorySearchModel.RecurringPaymentId }),
        Length = Model.RecurringPaymentHistorySearchModel.PageSize,
        LengthMenu = Model.RecurringPaymentHistorySearchModel.AvailablePageSizes,
        ColumnCollection = new List<ColumnProperty>
        {
            new ColumnProperty(nameof(RecurringPaymentHistoryModel.CustomOrderNumber))
            {
                Title = T("Admin.RecurringPayments.History.CustomOrderNumber").Text,
                ClassName =  NopColumnClassDefaults.Button,
                Width = "200",
                Render = new RenderCustom("renderColumnOrderInfo")
            },
            new ColumnProperty(nameof(RecurringPaymentHistoryModel.OrderStatus))
            {
                Title = T("Admin.RecurringPayments.History.OrderStatus").Text,
                Width = "200"
            },
            new ColumnProperty(nameof(RecurringPaymentHistoryModel.PaymentStatus))
            {
                Title = T("Admin.RecurringPayments.History.PaymentStatus").Text,
                Width = "200"
            },
            new ColumnProperty(nameof(RecurringPaymentHistoryModel.ShippingStatus))
            {
                Title = T("Admin.RecurringPayments.History.ShippingStatus").Text,
                Width = "200"
            },
            new ColumnProperty(nameof(RecurringPaymentHistoryModel.CreatedOn))
            {
                Title = T("Admin.RecurringPayments.History.CreatedOn").Text,
                Width = "100",
                Render = new RenderDate()
            }
        }
    })
    <script>
        function renderColumnOrderInfo(data, type, row, meta) {
            if (row.OrderId > 0) {
                var textRenderer = $.fn.dataTable.render.text().display;
                return '<a class="btn btn-default" href="@Url.Content("~/Admin/Order/Edit/")' + row.OrderId + '"><i class="fa fa-eye"></i>' + textRenderer(row.CustomOrderNumber) + ' - @T("Admin.Common.View")</a>';
            } else {
                return 'order item is deleted';
            }
        }
    </script>
</div>